package com.bytedance.improvingroad.binder

import android.os.Parcel
import android.os.Parcelable

/**
 * Created by chenxiong
 * date 12/14/21
 */
open class Book : Parcelable {
    var price = 0
    var name: String? = null

    override fun describeContents(): Int {
        return 0
    }

    override fun writeToParcel(dest: Parcel, flags: Int) {
        dest.writeInt(price)
        dest.writeString(name)
    }
    constructor(){}
    constructor(`in`: Parcel) {
        price = `in`.readInt()
        name = `in`.readString()
    }

    override fun toString(): String {
        return "Book{" +
                "price=" + price +
                ", name='" + name + '\'' +
                '}'
    }

    companion object {
         @JvmField
         val CREATOR: Parcelable.Creator<Book?> = object : Parcelable.Creator<Book?> {
            override fun createFromParcel(source: Parcel): Book {
                return Book(source)
            }

            override fun newArray(size: Int): Array<Book?> {
                return arrayOfNulls(size)
            }
        }
    }
}
